gi();

alert("<?php echo dirname($_SERVER['SCRIPT_NAME']); ?>");

function d(s){ var bed=document.getElementById('bed'); if(bed)bed.innerHTML+=s; }

function gi(loc){
  var widgets=['slider','msg','chk','sel','txt','ed','units','color','pixbox','wae','cal'];
  var tags=document.getElementsByTagName("*"),tagi,tagc=tags.length;
  var el,class,c=0,cwidgets=0;

  var errnoid=false;
  d(location.pathname);
  d("<br/>"+tagc+" els found");
  for(tagi=0;tagi<tagc;++tagi){
     el=tags[tagi];
    if(!el){ d('~kapotte el~'); }
    if(el.className){
      tagclass=el.className;
      if(widgets.indexOf(tagclass)!=-1){
        if(!el.id){ errnoid=true; }
        ++cwidgets;
        ajaxjs("<?php echo dirname($_SERVER['SCRIPT_NAME']); ?>/"+tagclass+".php?el="+el.id+"&p="+el.innerHTML);
        d("<br/>*"+tagi+"/"+tagc+"="+el.id+" : "+el.innerHTML+"*");
      }
    }
    else{ d('?'); }
  }
  d("<br/>"+cwidgets+" widgets found<hr/><p/>");
  if(errnoid){ alert('page includes widgets with id not set!'); }
  
}

function ajaxjs(cmd,div){
	if(!div)div='content'; ////
	if (window.XMLHttpRequest) var x=new XMLHttpRequest();
	else var x=new ActiveXObject("Microsoft.XMLHTTP");
	x.onreadystatechange=function(){ if(x.readyState==4 && x.status==200){    //alert(x.responseText);
		eval(x.responseText);
	}}
	x.open("GET",cmd,true); x.send();
}

/*
window.onDomReady = DomReady;
function DomReady(fn){
  if(document.addEventListener){ document.addEventListener("DOMContentLoaded", fn, false); } //W3C
  else{	document.onreadystatechange = function(){readyState(fn)} }  //IE
}*///EOF